
import { _decorator, instantiate, Node, Prefab } from 'cc';
import { Item_Status_Enum, Item_Type_Enum, SCENE_ENUM } from '../Enum';
import DataManager from '../Runtime/DataManager';
import { SceneManager } from './SceneManager';
const { ccclass, property } = _decorator;

@ccclass('H2SceneManager')
export class H2SceneManager extends SceneManager {
    @property(Prefab)
    keyPrefab: Prefab = null;

    @property(Node)
    keyPlaceholder: Node = null;
    type: SCENE_ENUM = SCENE_ENUM.H2;
    render(): void {
        super.render();
        this.items.destroyAllChildren();
        const key = DataManager.Instance.items.find(i => i.type === Item_Type_Enum.Key);
        if (key && key.status === Item_Status_Enum.Scene) {
            const keyNode = instantiate(this.keyPrefab);
            this.items.addChild(keyNode);
            keyNode.setPosition(this.keyPlaceholder.position);
        }
    }
}